package com.ruoyi.common.base;



import com.ruoyi.common.utils.DateUtils;

import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;

/**
 * 扩展isDeleted与updateTime的基类
 * 
 * @author wuwenchao
 *
 */
public class BaseModel implements Cloneable {

	public static final int NO = 0;
	public static final int YES = 1;
    /**
     * is_deleted (是否删除)
     */
    private Boolean isDeleted;
    
    /**
     * update_time (修改时间)
     */
    private Timestamp updateTime;

	/** 请求参数 */
	protected transient Map<String, Object> params;

	/** 其他数据 */
	protected transient Map<String, Object> extraData;

    public Object clone() throws CloneNotSupportedException{
    	return super.clone();
    }

	public Boolean getIsDeleted() {
		return null == isDeleted ? false : isDeleted;
	}

	public void setIsDeleted(Boolean isDeleted) {
		this.isDeleted = isDeleted;
	}

	public Timestamp getUpdateTime() {
		return null == updateTime ? DateUtils.getNewTimestamp() : updateTime;
	}

	public void setUpdateTime(Timestamp updateTime) {
		this.updateTime = updateTime;
	}

	public Map<String, Object> getParams()
	{
		if (params == null)
		{
			params = new HashMap<>();
		}
		return params;
	}

	public void setParams(Map<String, Object> params)
	{
		this.params = params;
	}

	public Map<String, Object> addParams(String key, Object value) {
		Map<String, Object> data = getParams();
		data.put(key, value);
		return data;
	}

	public Map<String, Object> getExtraData() {
		if (extraData == null)
		{
			extraData = new HashMap<>();
		}
		return extraData;
	}

	public void setExtraData(Map<String, Object> extraData) {
		this.extraData = extraData;
	}

	public Map<String, Object> addExtraData(String key, Object value) {
		Map<String, Object> data = getExtraData();
		data.put(key, value);
		return data;
	}
}
